/*
Copyright (c) 2025 HeZongLun
NahidaProject is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan
PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/

#pragma once

#include "XMLNode.h"

#include <iostream>
#include <vector>
#include <map>

namespace NahidaProject {
	class XMLElement : public NahidaProject::XMLNode {
	private:
		std::string name_;
		std::map<std::string, std::string> attributes_;
		std::vector<std::unique_ptr<XMLNode>> children_;

	public:
		explicit XMLElement(std::string name) : name_(std::move(name)) {

		}

		const std::string& GetName() const;
		const std::map<std::string, std::string>& GetAttributes() const;
		const std::vector<std::unique_ptr<XMLNode>>& GetChildren() const;
		void SetAttribute(const std::string& key, const std::string& value);
		std::string GetAttribute(const std::string& key) const;
		void AddChild(std::unique_ptr<XMLNode> child);
		std::vector<XMLElement*> FindElements(const std::string& name);
		XMLElement* GetElement(const std::string& name);
		std::string GetText() const;
		std::string ToString(int indent = 0) const override;
	};
}